<?php
 header("Content-Type:text/html;charset=utf-8");//防止网页中文乱码
 //接受提交的数据
//echo $_POST['username'];
//echo "<br/>";
//echo $_POST['message'];
//echo "<br/>";
//echo $_POST['sex'];
//echo "<br/>";
//echo $_POST['imgurl'];
 require'db_con.php';
 $username=$_REQUEST['username'];
 $sex=$_REQUEST['sex'];
 $message=$_REQUEST['message'];
 $imgurl=$_REQUEST['imgurl'];
 date_default_timezone_set('Asia/Shanghai');
 $m_date=date("Y-m-d h:i:s");
 $sql="insert into t_message(username,sex,message,imgurl,m_date) values('{$username}','{$sex}','{$message}','{$imgurl}','{$m_date}')";
 $rs=$db->query($sql);
 if ($rs==true)
 {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('留言成功!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 else{
      echo "<script language='javascript' type='text/javascript'>";
     echo "alert('留言失败!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }